"use strict"
const Service = require("egg").Service

class KfMessageService extends Service {
	constructor(ctx) {
		super(ctx)
		this.wechatpi = this.ctx.wechatAccount
	}
	/**
	 * 
	 * @param {{openid:string,text:string}} obj 
	 */
	async sendText(obj) {
		return await this.wechatpi.sendText(obj.openid, obj.text)
	}
	async sendTextFromCs(obj) {
		return await this.wechatpi.sendTextFromCs(obj.openid, obj.csAccount, obj.text)//cs_account
	}
	async sendImage(obj) {
		return await this.wechatpi.sendImage(obj.openid, obj.mediaId)
	}
	async sendImageFromCs(obj) {
		return await this.wechatpi.sendImageFromCs(obj.openid, obj.csAccount, obj.mediaId)
	}
	async sendVoice(obj) {
		return await this.wechatpi.sendVoice(obj.openid, obj.mediaId)
	}
	async sendVoiceFromCs(obj) {
		return await this.wechatpi.sendVoiceFromCs(obj.openid, obj.csAccount, obj.mediaId)
	}
	async sendVideo(obj) {
		return await this.wechatpi.sendVideo(obj.openid, obj.mediaId, obj.thumbId)
	}
	async sendVideoFromCs(obj) {
		return await this.wechatpi.sendVideoFromCs(obj.openid, obj.csAccount, obj.mediaId, obj.thumbId)
	}
	async sendMusic(obj) {
		return await this.wechatpi.sendMusic(obj.openid, obj.musicInfo)
	}
	async sendMusicFromCs(obj) {
		return await this.wechatpi.sendMusicFromCs(obj.openid, obj.csAccount, obj.musicInfo)
	}
	/**
	 * 
	 * @param {{openid:any,articles:Array.<{title:string,description:string,url:string,picurl:string}>}} obj 
	 */
	async sendNews(obj) {  //图文+外链接
		return await this.wechatpi.sendNews(obj.openid, obj.articles)
	}
	/**
	* 
	* @param {{openid:any,csAccount:string,articles:{title:string,description:string,url:string,picurl:string}}} obj 
	*/
	async sendNewsFromCs(obj) {//图文+外链接
		return await this.wechatpi.sendNewsFromCs(obj.openid, obj.csAccount, obj.articles)
	}
	async sendMpNews(obj) {  //图文+素材id
		return await this.wechatpi.sendMpNews(obj.openid, obj.mediaId)
	}
	async sendMpNewsFromCs(obj) {//图文+素材id
		return await this.wechatpi.sendMpNewsFromCs(obj.openid, obj.csAccount, obj.mediaId)
	}
	async sendCard(obj) {  //
		return await this.wechatpi.sendCard(obj.openid, obj.card)
	}
	async sendCardFromCs(obj) {  //
		return await this.wechatpi.sendCardFromCs(obj.openid, obj.csAccount, obj.card)
	}
	async setMessageStatus(obj) {
		return await this.wechatpi.setMessageStatus(obj.openid, obj.command)
	}
}
module.exports = KfMessageService